In [101]:
# this code will solve the following issue. Take 1 million dollars or be paid 1 cent a day and have it double each day. There are 31 work days
m=0.01 #money
pm=m #previous money
tm=0 #total money

print("On day 1 you would make",m,"with a total of 0.01") #prints how much you made the first day and how much you made in total

def add_commas(number): # a function for adding commas
    return "{money:,}".format(money=round(number,2))#formats the number added number to the function to add commas and returns it so other code can use it 
    #and also rounds it so theres only 2 digits after the decimal

for d in range(2,32): # d is days
    if d<3: # if its less than 3 days then we set previous to money
        pm=m
    else: # else we set previous money to total money
        pm=tm
    m*=2 #doubles the money
    tm=pm+m #setting total money
    print("On day",d,"you would make",add_commas(m),"with a total of",add_commas(pm+m)) #prints how much you would make and the total amount from adding previous money and money

tm=m+pm # setting total money one last time to previous money plus money
print("In total you would make",add_commas(tm)) #prints how you would make in total
On day 1 you would make 0.01 with a total of 0.01
On day 2 you would make 0.02 with a total of 0.03
On day 3 you would make 0.04 with a total of 0.07
On day 4 you would make 0.08 with a total of 0.15
On day 5 you would make 0.16 with a total of 0.31
On day 6 you would make 0.32 with a total of 0.63
On day 7 you would make 0.64 with a total of 1.27
On day 8 you would make 1.28 with a total of 2.55
On day 9 you would make 2.56 with a total of 5.11
On day 10 you would make 5.12 with a total of 10.23
On day 11 you would make 10.24 with a total of 20.47
On day 12 you would make 20.48 with a total of 40.95
On day 13 you would make 40.96 with a total of 81.91
On day 14 you would make 81.92 with a total of 163.83
On day 15 you would make 163.84 with a total of 327.67
On day 16 you would make 327.68 with a total of 655.35
On day 17 you would make 655.36 with a total of 1,310.71
On day 18 you would make 1,310.72 with a total of 2,621.43
On day 19 you would make 2,621.44 with a total of 5,242.87
On day 20 you would make 5,242.88 with a total of 10,485.75
On day 21 you would make 10,485.76 with a total of 20,971.51
On day 22 you would make 20,971.52 with a total of 41,943.03
On day 23 you would make 41,943.04 with a total of 83,886.07
On day 24 you would make 83,886.08 with a total of 167,772.15
On day 25 you would make 167,772.16 with a total of 335,544.31
On day 26 you would make 335,544.32 with a total of 671,088.63
On day 27 you would make 671,088.64 with a total of 1,342,177.27
On day 28 you would make 1,342,177.28 with a total of 2,684,354.55
On day 29 you would make 2,684,354.56 with a total of 5,368,709.11
On day 30 you would make 5,368,709.12 with a total of 10,737,418.23
On day 31 you would make 10,737,418.24 with a total of 21,474,836.47
In total you would make 21,474,836.47
In [ ]: